/*
 * 		Author : Xerxes
 * 		Program: 
 * 		Created On : 30.09.2011 07:46:27 BDT
 *      "I have not failed, I have just found 10000 ways that won't work.
 * 
*/


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define tp pair< int, pair<int,int> >
#define mmk( x, y , z ) mk( x, mk( y, z ) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
int N;
char g[101][101];
int ir,ic;

int r[]={-1,-1, -2,-2};
int c[]={+1,-1, +2,-2};

inline void Read(){
		CI(N);
		fo(i,0,N){
			fo(j,0,N){
				cin>>g[i][j];
			}
		}
		fo(i,0,N){
			fo(j,0,N){
				if( g[i][j]=='W' ){
					ir = i;
					ic = j;
				}
			}
		}
		
}
Int dp[101][101];
int K=1;
Int go( int rr, int cc ){
	if( rr==0 ){
		return (Int)1;
	}
	
	Int& res= dp[rr][cc];
	if( res!=-1 ){
		return res;
	}
	res = 0;
	fo(i,0,2){
		int tr = r[i]+rr;
		int tc = c[i]+cc;
		if( tr<0 || tc<0 || tr>=N || tc>=N )continue;
		if( g[tr][tc]=='.' ){
			Int var = go(tr,tc);
			res= (res+var)% (Int)1000007;
		}
		else if( g[tr][tc]=='B' ){
			
				int trr = r[i+2]+rr;
				int tcc = c[i+2]+cc;
				if( trr<0 || tcc<0 || trr>=N || tcc>=N ) continue;
				if( g[trr][tcc]=='.' ){
					Int var = go(trr,tcc);
					res= (res+var)% (Int)1000007;
				}
			
		}
	}
return res;
}
inline void Proc(){
	SET(dp,-1);
	Int var = go(ir,ic);
	printf("Case %d: %lld\n",K,var);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("in","rt",stdin);
    #endif
    int cases=1;
    for( CI(cases) ; cases ; --cases,++K ){
        Read();
        Proc();
    }

return 0;
}


